package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Lab;
import com.g8.pethospitallearnbackend.entity.LabExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface LabMapper {
    @SelectProvider(type=LabSqlProvider.class, method="countByExample")
    long countByExample(LabExample example);

    @DeleteProvider(type=LabSqlProvider.class, method="deleteByExample")
    int deleteByExample(LabExample example);

    @Delete({
        "delete from lab",
        "where lab_id = #{labId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String labId);

    @Insert({
        "insert into lab (lab_id, lab_type, ",
        "lab_name, lab_price, ",
        "clinical_significance, normal_level)",
        "values (#{labId,jdbcType=VARCHAR}, #{labType,jdbcType=VARCHAR}, ",
        "#{labName,jdbcType=VARCHAR}, #{labPrice,jdbcType=DOUBLE}, ",
        "#{clinicalSignificance,jdbcType=LONGVARCHAR}, #{normalLevel,jdbcType=LONGVARCHAR})"
    })
    int insert(Lab record);

    @InsertProvider(type=LabSqlProvider.class, method="insertSelective")
    int insertSelective(Lab record);

    @SelectProvider(type=LabSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="lab_id", property="labId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="lab_type", property="labType", jdbcType=JdbcType.VARCHAR),
        @Result(column="lab_name", property="labName", jdbcType=JdbcType.VARCHAR),
        @Result(column="lab_price", property="labPrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="clinical_significance", property="clinicalSignificance", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="normal_level", property="normalLevel", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Lab> selectByExampleWithBLOBs(LabExample example);

    @SelectProvider(type=LabSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="lab_id", property="labId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="lab_type", property="labType", jdbcType=JdbcType.VARCHAR),
        @Result(column="lab_name", property="labName", jdbcType=JdbcType.VARCHAR),
        @Result(column="lab_price", property="labPrice", jdbcType=JdbcType.DOUBLE)
    })
    List<Lab> selectByExample(LabExample example);

    @Select({
        "select",
        "lab_id, lab_type, lab_name, lab_price, clinical_significance, normal_level",
        "from lab",
        "where lab_id = #{labId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="lab_id", property="labId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="lab_type", property="labType", jdbcType=JdbcType.VARCHAR),
        @Result(column="lab_name", property="labName", jdbcType=JdbcType.VARCHAR),
        @Result(column="lab_price", property="labPrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="clinical_significance", property="clinicalSignificance", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="normal_level", property="normalLevel", jdbcType=JdbcType.LONGVARCHAR)
    })
    Lab selectByPrimaryKey(String labId);

    @UpdateProvider(type=LabSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Lab record, @Param("example") LabExample example);

    @UpdateProvider(type=LabSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Lab record, @Param("example") LabExample example);

    @UpdateProvider(type=LabSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Lab record, @Param("example") LabExample example);

    @UpdateProvider(type=LabSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Lab record);

    @Update({
        "update lab",
        "set lab_type = #{labType,jdbcType=VARCHAR},",
          "lab_name = #{labName,jdbcType=VARCHAR},",
          "lab_price = #{labPrice,jdbcType=DOUBLE},",
          "clinical_significance = #{clinicalSignificance,jdbcType=LONGVARCHAR},",
          "normal_level = #{normalLevel,jdbcType=LONGVARCHAR}",
        "where lab_id = #{labId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(Lab record);

    @Update({
        "update lab",
        "set lab_type = #{labType,jdbcType=VARCHAR},",
          "lab_name = #{labName,jdbcType=VARCHAR},",
          "lab_price = #{labPrice,jdbcType=DOUBLE}",
        "where lab_id = #{labId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Lab record);

    @Select("select lab_id from lab where lab_name=#{labName}")
    String selectLabIdByName(@Param("labName") String labName);

    @Select("select distinct lab_type from lab ")
    List<String> selectAllLabTypes();

    @Select("select * from lab where lab_id=#{labId}")
    Lab selectLabById(@Param("labId") String lab);
}